package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YonbipCorrespondingAuxiliaryItems;
import com.ruoyi.system.service.IYonbipCorrespondingAuxiliaryItemsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 辅助项值转换Controller
 * 
 * @author ruoyi
 * @date 2025-09-15
 */
@Controller
@RequestMapping("/system/auxiliaryItems")
public class YonbipCorrespondingAuxiliaryItemsController extends BaseController
{
    private String prefix = "system/auxiliaryItems";

    @Autowired
    private IYonbipCorrespondingAuxiliaryItemsService yonbipCorrespondingAuxiliaryItemsService;

    @RequiresPermissions("system:auxiliaryItems:view")
    @GetMapping()
    public String auxiliaryItems()
    {
        return prefix + "/auxiliaryItems";
    }

    /**
     * 查询辅助项值转换列表
     */
    @RequiresPermissions("system:auxiliaryItems:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YonbipCorrespondingAuxiliaryItems yonbipCorrespondingAuxiliaryItems)
    {
        startPage();
        List<YonbipCorrespondingAuxiliaryItems> list = yonbipCorrespondingAuxiliaryItemsService.selectYonbipCorrespondingAuxiliaryItemsList(yonbipCorrespondingAuxiliaryItems);
        return getDataTable(list);
    }

    /**
     * 导出辅助项值转换列表
     */
    @RequiresPermissions("system:auxiliaryItems:export")
    @Log(title = "辅助项值转换", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YonbipCorrespondingAuxiliaryItems yonbipCorrespondingAuxiliaryItems)
    {
        List<YonbipCorrespondingAuxiliaryItems> list = yonbipCorrespondingAuxiliaryItemsService.selectYonbipCorrespondingAuxiliaryItemsList(yonbipCorrespondingAuxiliaryItems);
        ExcelUtil<YonbipCorrespondingAuxiliaryItems> util = new ExcelUtil<YonbipCorrespondingAuxiliaryItems>(YonbipCorrespondingAuxiliaryItems.class);
        return util.exportExcel(list, "辅助项值转换数据");
    }

    /**
     * 新增辅助项值转换
     */
    @RequiresPermissions("system:auxiliaryItems:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存辅助项值转换
     */
    @RequiresPermissions("system:auxiliaryItems:add")
    @Log(title = "辅助项值转换", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YonbipCorrespondingAuxiliaryItems yonbipCorrespondingAuxiliaryItems)
    {
        return toAjax(yonbipCorrespondingAuxiliaryItemsService.insertYonbipCorrespondingAuxiliaryItems(yonbipCorrespondingAuxiliaryItems));
    }

    /**
     * 修改辅助项值转换
     */
    @RequiresPermissions("system:auxiliaryItems:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        YonbipCorrespondingAuxiliaryItems yonbipCorrespondingAuxiliaryItems = yonbipCorrespondingAuxiliaryItemsService.selectYonbipCorrespondingAuxiliaryItemsById(id);
        mmap.put("yonbipCorrespondingAuxiliaryItems", yonbipCorrespondingAuxiliaryItems);
        return prefix + "/edit";
    }

    /**
     * 修改保存辅助项值转换
     */
    @RequiresPermissions("system:auxiliaryItems:edit")
    @Log(title = "辅助项值转换", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YonbipCorrespondingAuxiliaryItems yonbipCorrespondingAuxiliaryItems)
    {
        return toAjax(yonbipCorrespondingAuxiliaryItemsService.updateYonbipCorrespondingAuxiliaryItems(yonbipCorrespondingAuxiliaryItems));
    }

    /**
     * 删除辅助项值转换
     */
    @RequiresPermissions("system:auxiliaryItems:remove")
    @Log(title = "辅助项值转换", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yonbipCorrespondingAuxiliaryItemsService.deleteYonbipCorrespondingAuxiliaryItemsByIds(ids));
    }
}
